package com.atguigu12.wapper;

import org.junit.Test;

/**
 * ClassName: wapperTest
 * Package: com.atguigu12.wapper
 * Description:
 *
 * @Author ZY
 * @Create 15:25
 * @Version 1.0
 */
public class WapperTest {



    /*
    基本数据类型--》包装类: (1)使用包装类的构造器 (2)使用包装类的静态方法valueOf()
    包装类--》基本数据类型: 调用包装类的xxxValue()
    */
    @Test
    public void test2(){
        Integer ii1 = new Integer(12);
        int i1 = ii1.intValue();
        i1 = i1 + 1;

        Float ff1 = new Float(12.3F);
        float f1 = ff1.floatValue();
        f1 = f1 + 1.1F;

        Boolean bb1 = new Boolean(true);
        boolean b1 = bb1.booleanValue();
        b1 = !b1;


    }


    @Test
    public void test1(){
        int i1 = 10;
        Integer ii1 = new Integer(i1);
        System.out.println(ii1.toString());

        float f1 = 12.3F;
        Float ff1 = new Float(f1);
        System.out.println(ff1.toString());

        String s1 = "32.1";
        Float ff2 = new Float(s1);
        System.out.println(ff2.toString());

        /*s1 = "abc";
        Float ff3 = new Float(s1);//报异常:NumberFormatException
        */

        boolean b1 = true;
        Boolean bb1 = new Boolean(b1);
        System.out.println(bb1.toString());

        String s2 = "true";
        s2 = "false123";
        s2 = "tRuE";
        Boolean bb2 = new Boolean(s2);
        System.out.println(bb2.toString());


        //valueOf
        int i2 = 10;
        Integer ii2 = Integer.valueOf(i2);
        Boolean b2 = Boolean.valueOf(s2);
        System.out.println(b2.toString());

    }

    @Test
    public void test3(){
        Account account = new Account();
        System.out.println(account.isFlag1);//false
        System.out.println(account.isFlag2);//null
    }


    @Test
    public void test4(){
        //自动装箱
        int i1 = 10;
        Integer ii1 = i1;
        System.out.println(ii1.toString());

        Integer ii2 = i1 + 1;//自动装箱
        Boolean bb1 = true;
        Float f1 = 12.3F;


        //自动拆箱
        int i2 = ii1;
        boolean b1 = bb1;

    }
}

class Account{
    boolean isFlag1;
    Boolean isFlag2;

    double balance1;

    Double balance2;//null

}